import request from "@/libs/request";

const basePath = '/appcloud-data' ;
const baseResourcePath = '/appcloud-resource' ;

export const apiUrls = {
	dleteFz : basePath + `/api/haproxy/delete/`,
	getActiveIp : basePath + `/api/haproxy/getActiveIp/`,
	getFzInfo : basePath + '/api/haproxy/getHaproxy',
	getFzListStatus : basePath + '/api/haproxy/getHaproxyStatus' ,
	getFzByPage : basePath + '/api/haproxy/list' ,
	creat : basePath + '/api/haproxy/save' ,
  update : basePath + '/api/haproxy/update' ,
}

export const apiUrlsResource = {
	create : baseResourcePath + `/api/haproxy/create/`,
	del : baseResourcePath + `/api/haproxy/del/`,
	delRule : baseResourcePath + `/api/haproxy/delRule/`,
	forward : baseResourcePath + `/api/haproxy/forward/`,
	start : baseResourcePath + `/api/haproxy/start/`,
	stop : baseResourcePath + `/api/haproxy/stop/`,
}

// 创建负载
export async function resourceCreat(params){
	return request( apiUrlsResource.create , {
      method:'POST',
      body:params
  })
}


// 删除负载
export async function resourceDel(params){
	return request( apiUrlsResource.del + params.id, {
      method:'POST',
      body:params
  })
}


// 删除规则配置
export async function stop(params){
	return request( apiUrlsResource.delRule + params.id , {
      method:'POST',
      body:params
  })
}


// 转发配置
export async function forward(params){
	return request( apiUrlsResource.forward , {
      method:'POST',
      body:params
  })
}

// 启动负载
export async function start(params){
	return request( apiUrlsResource.start + params.id , {
      method:'POST',
      body:params
  })
}


// 停止负载
export async function resourceStop(params){
	return request( apiUrlsResource.stop + params.id , {
      method:'POST',
      body:params
  })
}


/* - - - - - */


// 根据负载id删除负载
export async function dleteFz(params,id){
	return request( apiUrls.dleteFz + id , {
      method:'GET',
      body:params
  })
}


// 查询负载可用的ip信息
export async function getActiveIp(params){
	return request( apiUrls.getActiveIp + params.clusterId || "", {
      method:'GET',
  })
}



// 根据负载id或host查询负载详情
export async function getFzInfo(params){
	return request( apiUrls.getFzInfo , {
      method:'POST',
      body:params
  })
}

// 批量查询负载状态
export async function getFzListStatus(params){
	return request( apiUrls.getFzListStatus , {
      method:'POST',
      body:params
  })
}

// 根据条件分页查询负载均衡
export async function getFzByPage(params){
	return request( apiUrls.getFzByPage , {
      method:'POST',
      body:params
  })
}

// 创建负载均衡信息

export async function creat(params){
	return request( apiUrls.creat , {
      method:'POST',
      body:params
  })
}


// 更新负载均衡信息
export async function update(params){
	return request( apiUrls.update , {
      method:'POST',
      body:params
  })
}





